package esms.action.helper;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Wait;

import esms.action.ActionInterface;

/**
 * Wait for an element to appear
 * @author Carol
 *
 */
public class WaitForNode implements ActionInterface { 
	private String nodePath;
	private long timeoutInMilliseconds;

	public WaitForNode(String nodePath, long timeoutInMilliseconds) {
		this.nodePath = nodePath;
		this.timeoutInMilliseconds = timeoutInMilliseconds;
	}

	public void execute(final DefaultSelenium selenium) {
		Wait wait = new Wait() {
			public boolean until() {
				return selenium.isElementPresent(nodePath);
			}
		};
		wait.wait("", timeoutInMilliseconds);
	}
}
